home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1986 July / Ahoy_Magazine_86-07_1986_Double_L.d64 / comal article < prev    next >
Text File  |  2022-10-26  |  5KB  |  197 lines

  1.          FRUSTRATION FACTORS
  2.  
  3.             by Joel E Rea
  4.  
  5.  
  6. Learning to program can be a highly
  7. frustrating experience when using any
  8. of the popular languages, such as
  9. BASIC, Forth, Pascal, C, Modula-2,
  10. LISP, etc. These are frustrating for
  11. different reasons:
  12.  
  13. 1. Interpreted, non-structured
  14. languages like BASIC are easy to
  15. learn, but cause frustration later on
  16. when the programmer wants to actually
  17. create a program of his own which
  18. does something useful! It's no fun
  19. trying to decipher and debug one's
  20. code when it consists of lines like:
  21.  
  22. 10 gosub5000:onmgoto100,200,500
  23.  
  24. 2. Compiled, structured languages
  25. like Pascal, C, Modula-2, etc.
  26. eliminate that particular frustration
  27. factor. You can see how much easier
  28. it would be to decipher and debug if
  29. the above line read (in Pascal):
  30.  
  31.       command := mainMenu; 
  32.       CASE command OF 
  33.         1:  loadSprite; 
  34.         2:  editSprite; 
  35.         3:  saveSprite 
  36.       END;  (* CASE command *)
  37.  
  38. The problem is, learning the language
  39. itself, and entering a program are
  40. frustrating. You cannot experiment in
  41. a simple "immediate mode" like you
  42. can in BASIC! You must write a whole
  43. program, declaring variables, etc.
  44. just to experiment with a new
  45. statement or function! BASIC
  46. eliminates this particular
  47. frustration factor.
  48.  
  49. 3. Languages like Logo are both
  50. interactive and structured. However,
  51. the concepts they teach are not
  52. easily applied to other, more
  53. standard algorithmic languages! Logo
  54. has lists but no arrays, for example.
  55. Trying to convert a list-processing
  56. program to a language that supports
  57. only arrays is frustrating! 
  58.  
  59. 4. Languages like Forth are also both
  60. structured and interactive, but the
  61. syntax is not intuitive (a flaw
  62. shared by APL). One has to either
  63. know the language well, or look quite
  64. closely to tell that the following
  65. will print 27:
  66.  
  67.       : cube dup dup * * ; 
  68.       3 cube . cr
  69.  
  70. Ten years ago, Danish educator Borge
  71. Christensen recognized the
  72. frustration factors inherent in the
  73. popular computer languages used for
  74. teaching programming. He knew that a
  75. non-frustrating language was needed.
  76. Thus was born COMAL, which stands for
  77. COMmon Algorithmic Language.
  78.  
  79. COMAL eliminates FF#1 (Frustration
  80. Factor #1), found in BASIC and
  81. related languages, because it is a
  82. fully structured language. Program
  83. logic is easy to follow, and programs
  84. are easy to debug. Indeed, the syntax
  85. of COMAL is almost identical with the
  86. pseudo-syntax many programmers use to
  87. plan their programs out in before
  88. they write them in a programming
  89. language!
  90.  
  91. COMAL eliminates FF#2, found in
  92. compiled languages like Pascal,
  93. because it is a fully interactive
  94. language like BASIC. Actually, it is
  95. even MORE interactive than Commodore
  96. and most other versions of BASIC,
  97. because it gives the user immediate
  98. feedback on syntax errors as soon as
  99. they enter a line of code, even if it
  100. is a line of a program. Not only
  101. that, it usually tells exactly why
  102. the line was wrong! For example, if
  103. you type:
  104.  
  105. 10 print "The sine of 9 is"; sin)9)
  106.  
  107. COMAL 2.0 on the C64 immediately
  108. says:
  109.  
  110. "(" expected, not ")"
  111.  
  112. and returns the cursor to the line,
  113. right over the ")" between "sin" and
  114. "9"! You don't have to wait to RUN
  115. the program to find your typos! 
  116.  
  117. COMAL also eliminates FF#3, found in
  118. languages like Logo, because it is a
  119. true imperative, algorithmic language
  120. like BASIC, FORTRAN, COBOL, Pascal,
  121. and the vast majority of other
  122. languages actually used in jobs!
  123.  
  124. Finally, COMAL eliminates FF#4, found
  125. in languages like Forth, C and APL,
  126. because it's syntax is easy to
  127. understand, even for someone who has
  128. never seen a COMAL program before!
  129. For example: 
  130.  
  131. FUNC celsius(fahr) 
  132.   RETURN (fahr-32)*(5/9) 
  133. ENDFUNC celsius 
  134. //
  135. FUNC farenheit(cels) 
  136.   RETURN cels*(9/5)+32 
  137. ENDFUNC farenheit 
  138. //
  139. DIM choice$ OF 1
  140. PRINT "Temperature Converter" 
  141. PRINT 
  142. REPEAT 
  143.   PRINT "Convert to Farenheit";
  144.   PRINT "or Celsius, or Quit";
  145.   INPUT "(f/c/q): " : choice$
  146.   IF choice$ IN "CcFf" THEN
  147.     INPUT "Temperature? ": temp
  148.   ENDIF
  149.   CASE choice$ OF 
  150.   WHEN "C","c" 
  151.     PRINT temp;"F =";
  152.     PRINT celsius(temp);"C"
  153.   WHEN "F","f" 
  154.     PRINT temp;"C =";
  155.     PRINT farenheit(temp);"F"
  156.   WHEN "Q","q" 
  157.     PRINT "Okay, bye!" 
  158.   OTHERWISE 
  159.     PRINT "C'mon, either type";
  160.     PRINT "'Farenheit', 'Celsius'";
  161.     PRINT "or 'Quit'!"
  162.   ENDCASE 
  163. UNTIL choice$ IN "Qq" 
  164.  
  165. As you can see from the above
  166. program, COMAL's syntax is clean, not
  167. obscure. By the way, the
  168. capitalization of keywords and the
  169. indentation of program structures is
  170. handled automatically by the COMAL
  171. LISTer routine. Line numbers are used
  172. in COMAL only as references for
  173. editing. While GOTO exists, it is
  174. used with named labels only, as in: 
  175.  
  176. IF choice$ IN "Hh" THEN GOTO help
  177.  
  178. where the "help" routine would begin
  179. with the label: 
  180.  
  181. help:
  182.  
  183. In Commodore BASIC 2.0, this might
  184. read as follows: 
  185.  
  186. ifleft$(c$,1)="H"then45
  187. ifleft$(c$,1)="h"then45
  188.  
  189. C64 COMAL 2.0 lets you either LIST a
  190. program with line numbers, or DISPLAY
  191. it without line numbers!
  192.  
  193. [Editor's Note: The only difference
  194. between COMAL 2.0 and COMAL 0.14 is
  195. that COMAL 0.14 does not captitalize
  196. keywords like COMAL 2.0 does.]
  197.